<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<link rel="stylesheet" type="text/css" href="../../../Themes/default/easyui.css">
		<link rel="stylesheet" type="text/css" href="../../../Themes/icon.css">
		<link rel="stylesheet" type="text/css" href="../../../CSS/demo.css">
		<link rel="stylesheet" type="text/css" href="../../../CSS/common.css">
		<script type="text/javascript" src="../../../JS/jquery.min.js"></script>
		<script type="text/javascript" src="../../../JS/jquery.easyui.min.js"></script>
		<script type="text/javascript" src="../../../JS/common.js"></script>
		<script type="text/javascript" src="../../../JS/SHA-1.js"></script>
	</head>

	<body style="padding: 0px;">
		<div class="easyui-layout" style="width:100%;height:500px;">
			<div data-options="region:'center'">
				<div>
					<table id="dg" title="销售单信息" width="100%">
					</table>
				</div>
			</div>
		</div>
		<div id="toolbar"></div>
	</body>
	<script>
		var currid = getID(); /**得到当前界面的ID**/
		var content = ""; /*定义一个空的content*/
		content = AddToolBars(3); /**根据用户的权限，来决定生成ToolBar的哪些功能**/
		content += AddToolBar(TOOLBAR_REDO);
		$("#toolbar").append(content); /*在ID=toolbar的标记后面添加content中的内容*/

		function AddToolBars(type) {
			var data = [{
				"icon": "icon-print",
				"func": "print('A')",
				"functionname": "打印原始销售单"
			}, {
				"icon": "icon-print",
				"func": "print('B')",
				"functionname": "打印执行销售单"
			}, {
				"icon": "icon-redo",
				"func": "ExecuteSalesOrder()",
				"functionname": "执行销售单"
			}, ]
			var content = "";
			var s;
			for(var i = 0; i < 3; i++) {
				s = type & (1 << i);
				if(s != 0) {
					content += "<a href=\"javascript:void(0)\" class=\"easyui-linkbutton\"  iconCls=\"" + data[i].icon + "\" plain='true' onclick=\"" + data[i].func + "\">" + data[i].functionname + "</a>";
				}
			}
			return content;
		}

		function print(type) {
			var row = $('#dg').datagrid('getSelections');
			if(row.length == 0) {
				$.messager.alert('Info', "没有选中");
				return;
			}
			var selectedID = "";
			if(type == "A") {
				for(var i = 0; i < row.length; i++) {
					selectedID = selectedID + row[i].ORIGINALORDER_ID + ";";
				}
				var pLocation = "SalesOrderAPrint.html?IDS=" + selectedID;
			}
			if(type == "B") {
				for(var i = 0; i < row.length; i++) {
					selectedID = selectedID + row[i].ID + ";";
				}
				var pLocation = "SalesOrderPrint.html?TYPE=B;" + selectedID;
			}

			window.open(pLocation); /*打开pLocation中的链接html文档*/
		}

		function redodata() {
			checkAllData("/logistics/salesorder/list.do?LIMIT_STATE=" + "收货");
		}

		$('#dg').datagrid({
			url: RemoteLinkAddress + '/logistics/salesorder/list.do?LIMIT_STATE=' + '收货',
			toolbar: '#toolbar',
			method: 'get',
			pagination: 'true',
			rownumbers: 'true',
			autoRowHeight: 'true',
			fitColumns: 'false',
			height: 440,
			/*表格中的列名以及各自列名的ID*/
			columns: [
				[{
					field: 'ck',
					checkbox: 'true',
				}, {
					field: 'ORIGINALORDER_ID',
					title: '编号',
					width: '0%',
					align: 'center'
				}, {
					field: 'ID',
					title: '编号',
					width: '5%',
					align: 'center'
				}, {
					field: 'CUSTOMER_TYPE',
					title: '用户组',
					width: '23%',
					align: 'center'
				}, {
					field: 'CUSTOMER_NAME',
					title: '配送单位',
					width: '23%',
					align: 'center'
				}, {
					field: 'DISTRIBUTION_DATE',
					title: '配送时间',
					width: '20%',
					align: 'center'
				}, {
					field: "STATE",
					title: '订单状态',
					width: '20%',
					align: 'center'
				}]
			],
			onDblClickRow: function(index, row) {
				var pLocation = "";
				pLocation = "UI/LOGISTICS/SalesOrder/SalesOrderAdd.html?id=" + row.ID; /*将BoothManagementAdd.html的相对路径与被选中行的ID赋值给pLocation*/
				AddTabIn("销售单详情", parent.parent.$("#tabs"), pLocation);
				console.log(pLocation);

			},
			onClickRow: function(index, row) {

			}
		});
		$('#dg').datagrid('hideColumn', 'ORIGINALORDER_ID'); //隐藏第一列

		var auth = "admin;" + hex_sha1("admin1");
	</script>

</html>